<!DOCTYPE html>
<html>
<head>
    <title>个人中心</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="description" content="木兰湾管理系统">
    <script type="text/javascript" src="../../static/include/header-css.js"></script>
    <!--swiper组件-->
    <link rel="stylesheet" href="../../static/css/swiper.min.css">
    <style>
        .swiper-container {
            background: #F8F8FF;
            height: 30px;
            align-content: center;
        }
    </style>
</head>
<body ontouchstart>
<div class="weui-cells__title" align="center">
    <div class="weui-avatar-circle">
        <img src="../../static/image/logo-large.png">
        <!-- 加认证标记
        <span class="weui-icon-success weui-icon-safe-warn"></span>
        -->
    </div>
    <label id="version"></label>
    <br>
    <label id="username"></label>
</div>
<div class="weui-grids">
    <a href="userRewardPoints.html" class="weui-grid js_grid">
        <div class="weui-grid__icon">
            <img src="../../static/image/points-l.png" alt="">
        </div>
        <p class="weui-grid__label">
            <label id="dailyRewardPointsStat">当日积分</label>
        </p>
    </a>
    <a href="todayCalendar.html" class="weui-grid js_grid">
        <div class="weui-grid__icon">
            <img src="../../static/image/calendar-l.png" alt="">
        </div>
        <p class="weui-grid__label">
            今日任务<label style="color: red" id="todayCalendars"></label>
        </p>
    </a>
    <a href="../fund/budgetStat.html" class="weui-grid js_grid">
        <div class="weui-grid__icon">
            <img src="../../static/image/budget-l.png" alt="">
        </div>
        <p class="weui-grid__label">
            预算统计
        </p>
    </a>
</div>
<!--系统通知-->
<div class="swiper-container">
    <div class="swiper-wrapper" id="messageList">
    </div>
</div>

<!--功能选项-->
<div class="weui-cells__title">功能选项>>>></div>
<div class="weui-cells">

    <a class="weui-cell weui-cell_access" href="userScore.html">
        <div class="weui-cell__hd"><img src="../../static/image/score.png" alt=""
                                        style="width:20px;margin-right:5px;display:block"></div>
        <div class="weui-cell__bd">
            <p>评分查看</p>
        </div>
        <div class="weui-cell__ft"></div>
    </a>
    <a class="weui-cell weui-cell_access" href="todayTimeline.html">
        <div class="weui-cell__hd"><img src="../../static/image/timeline.png" alt=""
                                        style="width:20px;margin-right:5px;display:block"></div>
        <div class="weui-cell__bd">
            <p>流水记录</p>
        </div>
        <div class="weui-cell__ft"></div>
    </a>
    <a class="weui-cell weui-cell_access" href="../log/userMessage.html">
        <div class="weui-cell__hd"><img src="../../static/image/message.png" alt=""
                                        style="width:20px;margin-right:5px;display:block"></div>
        <div class="weui-cell__bd">
            <p>我的消息</p>
        </div>
        <div class="weui-cell__ft"></div>
    </a>
    <a class="weui-cell weui-cell_access" href="customService.html">
        <div class="weui-cell__hd"><img src="../../static/image/cs.png" alt=""
                                        style="width:20px;margin-right:5px;display:block"></div>
        <div class="weui-cell__bd">
            <p>智能客服</p>
        </div>
        <div class="weui-cell__ft"></div>
    </a>
    <a class="weui-cell weui-cell_access" href="../wx/wechart.html">
        <div class="weui-cell__hd"><img src="../../static/image/wechat.png" alt=""
                                        style="width:20px;margin-right:5px;display:block"></div>
        <div class="weui-cell__bd">
            <p>微信绑定</p>
        </div>
        <div class="weui-cell__ft"></div>
    </a>
    <a class="weui-cell weui-cell_access" href="../wx/wxScan.html">
        <div class="weui-cell__hd"><img src="../../static/image/scan.png" alt=""
                                        style="width:20px;margin-right:5px;display:block"></div>
        <div class="weui-cell__bd">
            <p>微信扫码</p>
        </div>
        <div class="weui-cell__ft"></div>
    </a>
    <a class="weui-cell weui-cell_access" href="userSetting.html">
        <div class="weui-cell__hd"><img src="../../static/image/user.png" alt=""
                                        style="width:20px;margin-right:5px;display:block"></div>
        <div class="weui-cell__bd">
            <p>个人设置</p>
        </div>
        <div class="weui-cell__ft"></div>
    </a>
</div>
</div>
<a href="javascript:logout();" class="weui-btn weui-btn_warn">退出系统</a>
<br>
<script type="text/javascript" src="../../static/include/footer-js.js"></script>
<!--swiper组件-->
<script type="text/javascript" src="../../static/js/swiper.min.js"></script>

<script type="text/javascript">
    $(function () {
        dailyRewardPointsStat();
        loadUserInfo();
        getMessageData();
    });
    function logout() {
        $.confirm("您是否要退出系统?", "退出系统?", function () {
            var url = '/main/logout';
            doAjax(null, url, 'POST', false, function (data) {
                window.parent.location.href = 'login.html';
            });
        }, function () {
            //$.toptip('已取消', 'warning');
        });
    }
    function getMessageData() {
        var para ={
            page:1,
            pageSize:5,
            needTotal:false
        };
        var url="/userMessage/getMyList";
        doAjax2(para, url, 'GET', false, false, function (data) {
            var html='';
            var n=data.rows.length;
            if(n>0){
                for(var i=0;i<n;i++){
                    var rowData = data.rows[i];
                    var title = '<img src="../../static/image/message-s.png"><a href="javascript:showMessageDetail('+rowData.id+')"><font color="#6B6B6B">' + rowData.title + '</font></a>';
                    var tillNow = tillNowSeconds(null,rowData.createdTime);
                    if(tillNow>=-4*3600){
                        title+='<img src="../../static/image/new-s.png">';
                    }
                    html+='<div class="swiper-slide" align="center" >'+title+'</div>';
                }
            }else{
                html+='<div class="swiper-slide" align="center" >暂无新的消息</div>';
            }
            setElementInnerHTML("messageList", html);
            var mySwiper = new Swiper('.swiper-container', {
                autoplay: {
                    delay: 3000,
                    stopOnLastSlide: false,
                    disableOnInteraction: true,
                }
            });
        });
    }
    function showMessageDetail(id) {
        var url = '/userMessage/get?id='+id;
        doAjax(null, url, 'GET', false, function (data) {
            showInfoMsg(data.content);
        });
    }
    function dailyRewardPointsStat() {
        var url = '/userRewardPointRecord/dailyStat';
        doAjax2(null, url, 'GET', false, false, function (data) {
            var ss = '';
            if (data) {
                if (data.totalPoints >= 0) {
                    ss = '<a href="javascript:showDailyRewardPointsStat()"><font color="green">(积分:+' + data.totalPoints + ')</font></a>';
                } else {
                    ss = '<a href="javascript:showDailyRewardPointsStat()"><font color="red">(积分:' + data.totalPoints + ')</font></a>';
                }
            } else {
                ss = '<a href="javascript:showDailyRewardPointsStat()"><font color="green">(积分:+0)</font></a>';
            }
            setElementInnerHTML("dailyRewardPointsStat", ss);
        });
    }

    function loadUserInfo() {
        var url = '/main/myInfo';
        doAjax2(null, url, 'GET', false, false, function (data) {
            if (data.nickname) {
                setElementInnerHTML("username", data.nickname);
            } else {
                setElementInnerHTML("username", data.username);
            }
            setElementInnerHTML("version", 'V' + data.version);
            var todayCalendars = data.todayCalendars;
            if (todayCalendars > 0) {
                setElementInnerHTML("todayCalendars", '(' + data.todayCalendars + ')');
            }
        });
    }
</script>
</body>
</html>